#include <stdio.h>
#include <conio.h>
#define N 10000


int Delitsum(int Chislo)
{
	int sum=0;
	for(int i=1;i<=Chislo/2;i++)
		if (Chislo%i==0) sum+=i;
	return sum;
}

int main()
{
	int a,b,c,buf1=0,buf2=0;
	printf("Spisok drujestvennih chisel: \n");
	for(int j=0;j<N;j++)
	{
		a=Delitsum(j);
		b=Delitsum(a);
		if((b==j)&&(a!=b)&&(j!=buf1)&&(a!=buf2))
			{
				printf("%d - %d \n",j,a);
				buf1=a;//swapaem
				buf2=j;
			}
	}
	getch();
	return 0;
}
